<template>
	<div class="search searchBox clearfix">
		<el-form :model="form" >


			<el-form-item label="公司名称" v-if="options.companyname">
				<el-input v-model="form.companyname" placeholder="请输入企业名称"></el-input>
			</el-form-item>

			<el-form-item label="充值用户名称" v-if="options.payusername">
				<el-input v-model="form.payusername" placeholder="请输入充值人名称"></el-input>
			</el-form-item>




			<el-form-item label="发起人姓名" v-if="options.initiator ">
				<el-input v-model="form.initiator" placeholder="请输入发起人姓名"></el-input>
			</el-form-item>

			<el-form-item label="合同名称" v-if="options.contractname">
				<el-input v-model="form.contractname" placeholder="请输入合同名称"></el-input>
			</el-form-item>


			<el-form-item label="用户姓名" v-if="options.remark1">
				<el-input v-model="form.remark1" placeholder="请输入用户姓名"></el-input>
			</el-form-item>

			<el-form-item label="充值用户电话" v-if="options.telnum">
				<el-input v-model="form.telnum" placeholder="请输入充值人电话"></el-input>
			</el-form-item>



			<el-form-item label="测评标题" v-if="options.remark2">
				<el-select v-model="form.remark2">
					<el-option label="小白入门版" value="2"></el-option>
					<el-option label="职场达人版" value="1"></el-option>
					<el-option label="职场精英版" value="3"></el-option>
					<el-option label="心理健康体检" value="6"></el-option>
					<el-option label="领导力测试" value="7"></el-option>
				</el-select>

			</el-form-item>

			<el-form-item label="测评结果" v-if="options.module">
				<el-select v-model="form.module">
					<el-option label="未完成" value="0"></el-option>
					<el-option label="完成" value="1"></el-option>
				</el-select>
			</el-form-item>

			<!-- 线下门店 -->
			<el-form-item label="门店名称" v-if="options.shopName">
				<el-input v-model="form.shopName" placeholder="请输入门店名称"></el-input>
			</el-form-item>

			<el-form-item label="门店创建人名称" v-if="options.shopusername">
				<el-input v-model="form.shopusername" placeholder="请输入门店创建人名称"></el-input>
			</el-form-item>
			<el-form-item label="入职者名称" v-if="options.name">
				<el-input v-model="form.name" placeholder="请输入入职者名称"></el-input>
			</el-form-item>
			<el-form-item label="代招企业名称" v-if="options.replaceCompanyname">
				<el-input v-model="form.replaceCompanyname" placeholder="请输入代招企业名称"></el-input>
			</el-form-item>

			<!-- 被调 -->
			<el-form-item label="发起人姓名" v-if="options.bkusername">
				<el-input v-model="form.bkusername" placeholder="请输入发起人姓名"></el-input>
			</el-form-item>
			<el-form-item label="被调人姓名" v-if="options.gname">
				<el-input v-model="form.gname" placeholder="请输入被调人姓名"></el-input>
			</el-form-item>

			<el-form-item label="调查结果" v-if="options.gumStatus">
				<el-select v-model="form.gumStatus">
					<el-option value="2" label="待授权"></el-option>
					<el-option value="3" label="调查中"></el-option>
					<el-option value="5" label="已完成"></el-option>
				</el-select>

			</el-form-item>


			<!-- 企业招聘 -->

			<el-form-item label="hr姓名" v-if="options.hrname">
				<el-input v-model="form.hrname" placeholder="请输入hr姓名"></el-input>
			</el-form-item>
			<el-form-item label="入职者姓名" v-if="options.username">
				<el-input v-model="form.username" placeholder="请输入入职者姓名"></el-input>
			</el-form-item>
			<el-form-item label="会员名称" v-if="options.noUserName">
				<el-input v-model="form.userName" placeholder="请输入会员名称"></el-input>
			</el-form-item>
			<el-form-item label="项目名称" v-if="options.noProjectName">
				<el-input v-model="form.projectName" placeholder="请输入项目名称"></el-input>
			</el-form-item>
			<el-form-item label="门店名称" v-if="options.noShopName">
				<el-input v-model="form.shopName" placeholder="请输入项目名称"></el-input>
			</el-form-item>
			<el-form-item label="姓名" v-if="options.noFounder">
				<el-input @blur="setform" v-model="form.createusername" placeholder="请输入真实姓名"></el-input>
			</el-form-item>
			<el-form-item label="下级入职人员姓名" v-if="options.noSubordinate">
				<el-input v-model="form.subordinate" placeholder="请输入项目名称"></el-input>
			</el-form-item>
			<el-form-item label="下级入职公告岗位" v-if="options.noPost">
				<el-input v-model="form.post" placeholder="请输入项目名称"></el-input>
			</el-form-item>
			<el-form-item label="身份证号码" v-if="options.noCardnum">
				<el-input @blur="setform" v-model="form.identity" placeholder="请输入身份证号码"></el-input>
			</el-form-item>
			<el-form-item label="模板名称" v-if="options.noTemplateName">
				<el-input v-model="form.templateName" placeholder="请输入模板名称"></el-input>
			</el-form-item>
			<el-form-item label="日期" v-if="options.noTime">
				<el-date-picker v-model="form.startDate" type="date" placeholder="选择日期" format="yyyy-MM-dd"
					value-format="yyyy-MM-dd" style="width:140px"></el-date-picker>~
				<el-date-picker v-model="form.endDate" type="date" placeholder="选择日期" format="yyyy-MM-dd"
					value-format="yyyy-MM-dd" style="width:140px"></el-date-picker>
			</el-form-item>

			<el-form-item style="width:288px;text-align:center;float: right;">
				<el-button type="primary" @click="search" size="small" class="searchBtn">查询</el-button>
			</el-form-item>


			<el-form-item label="手机号码" v-if="options.phonenum">
				<el-input v-model="form.phonenum" placeholder="请输入充值人电话"></el-input>
			</el-form-item>
		</el-form>
	</div>
</template>

<script>
	export default {
		props: {
			options: {
				required: true,
				type: Object
			}
		},
		data() {
			return {
				searchform: {},
				form: {
					telnum: '',
					payusername: '', //充值人姓名
					initiator: '', //发起人名称
					contractname: '', //合同名称
					remark1: '', //用户姓名
					remark2: '', //测评标题
					module: '', //测试结果
					shopName: '', //门店名称
					shopusername: '', //门店创建人名称
					name: '', //入职者名称
					replaceCompanyname: '', //待招企业名称
					bkusername: '', //被调人
					gumStatus: '', //状态
					gname: '', //被调发起人
					companyname: '', //企业名称
					hrname: '', //hr姓名
					username: '', //入职者姓名
					companyName: '', //企业名称
					userName: '', //会员名称
					projectName: '', //项目名称
					shopName: '', //门店名称
					createusername: '', //创建者姓名
					subordinate: '', //下级入职人员姓名
					post: '', //下级入职公告岗位
					identity: '', //身份证号码
					templateName: '', //模板名称
					startDate: '', //开始时间
					endDate: '', //截至时间
				}
			}
		},
		watch: {

		},
		methods: {
			search() {
				let form = {};
				if (this.options.phonenum && this.form.phonenum != '') {
					form.phonenum = this.form.phonenum;
				}
				if (this.options.telnum && this.form.telnum != '') {
					form.telnum = this.form.telnum;
				}
				if (this.options.payusername && this.form.payusername != '') {
					form.payusername = this.form.payusername;
				}
				if (this.options.remark1 && this.form.remark1 != '') {
					form.remark1 = this.form.remark1;
				}
				if (this.options.initiator && this.form.initiator != '') {
					form.initiator = this.form.initiator;
				}

				if (this.options.contractname && this.form.contractname != '') {
					form.contractname = this.form.contractname;
				}

				if (this.options.remark2 && this.form.remark2 != '') {
					form.remark2 = this.form.remark2;
				}
				if (this.options.module && this.form.module != '') {
					form.module = this.form.module;
				}



				if (this.options.shopName && this.form.shopName != '') {
					form.shopName = this.form.shopName;
				}
				if (this.options.shopusername && this.form.shopusername != '') {
					form.shopusername = this.form.shopusername;
				}

				if (this.options.name && this.form.name != '') {
					form.name = this.form.name;
				}

				if (this.options.replaceCompanyname && this.form.replaceCompanyname != '') {
					form.replaceCompanyname = this.form.replaceCompanyname;
				}

				if (this.options.bkusername && this.form.bkusername != '') {
					form.bkusername = this.form.bkusername;
				}
				if (this.options.gumStatus && this.form.gumStatus != '') {
					form.gumStatus = this.form.gumStatus;
				}
				if (this.options.gname && this.form.gname != '') {
					form.gname = this.form.gname;
				}
				if (this.options.companyname && this.form.companyname != '') {
					form.companyname = this.form.companyname;
				}
				if (this.options.hrname && this.form.hrname != '') {
					form.hrname = this.form.hrname;
				}
				if (this.options.username && this.form.username != '') {
					form.username = this.form.username;
				}
				if (this.options.noCompanyName && this.form.companyName != '') {
					form.companyName = this.form.companyName;
				}
				if (this.options.noUserName && this.form.userName != '') {
					form.userName = this.form.userName;
				}
				if (this.options.noProjectName && this.form.projectName != '') {
					form.projectName = this.form.projectName;
				}
				if (this.options.noShopName && this.form.shopName != '') {
					form.shopName = this.form.shopName;
				}
				if (this.options.noFounder && this.form.createusername != '') {
					form.createusername = this.form.createusername;
				}
				if (this.options.noSubordinate && this.form.subordinate != '') {
					form.subordinate = this.form.subordinate;
				}
				if (this.options.noPost && this.form.post != '') {
					form.post = this.form.post;
				}
				if (this.options.noCardnum && this.form.identity != '') {
					form.identity = this.form.identity;
				}

				if (this.options.noTemplateName && this.form.templateName != '') {
					form.templateName = this.form.templateName;
				}
				if (this.options.noTime && this.form.startDate && this.form.endDate && Date.parse(this.form.startDate) >
					Date.parse(this.form.endDate)) {
					this.$message({
						message: "结束时间不能早于开始时间",
						type: "warning"
					});
					return false;
				}
				if (this.form.startDate) {
					form.startDate = this.form.startDate;
				}
				if (this.form.endDate) {
					form.endDate = this.form.endDate;
				}

				this.$emit('search', form);

			},
			setform() {
				console.log(1)
				let form = {};
				if (this.options.noCompanyName && this.form.companyName != '') {
					form.companyName = this.form.companyName;
				}
				if (this.options.noUserName && this.form.userName != '') {
					form.userName = this.form.userName;
				}
				if (this.options.noProjectName && this.form.projectName != '') {
					form.projectName = this.form.projectName;
				}
				if (this.options.noShopName && this.form.shopName != '') {
					form.shopName = this.form.shopName;
				}
				if (this.options.noFounder && this.form.createusername != '') {
					form.createusername = this.form.createusername;
				}
				if (this.options.noSubordinate && this.form.subordinate != '') {
					form.subordinate = this.form.subordinate;
				}
				if (this.options.noPost && this.form.post != '') {
					form.post = this.form.post;
				}
				if (this.options.noCardnum && this.form.identity != '') {
					form.identity = this.form.identity;
				}

				if (this.options.noTemplateName && this.form.templateName != '') {
					form.templateName = this.form.templateName;
				}
				if (this.options.noTime && this.form.startDate && this.form.endDate && Date.parse(this.form.startDate) >
					Date.parse(this.form.endDate)) {
					this.$message({
						message: "结束时间不能早于开始时间",
						type: "warning"
					});
					return false;
				}
				if (this.form.startDate) {
					form.startDate = this.form.startDate;
				}
				if (this.form.endDate) {
					form.endDate = this.form.endDate;
				}
				console.log(form)
				this.$store.commit('setform', form);
			}

		},
		created() {

		}
	}
</script>

<style scoped="scoped">
	.search {
		margin: 20px 0;
	}

	.el-form .el-form-item .el-form--inline .el-form-item__label {
	    float: left;
	    display: inline-block;
	}

	.el-form-item {
		min-width: 300px;
		float: left;
		margin-right: 20px;
	}

	.searchBtn {
		width: 140px;
	}

	.searchBox {
		padding: 0 30px;
	}
</style>
